package com.example.boxuegu;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class SQLiteHeloer extends SQLiteOpenHelper {
    private static final int DB_VERSION = 4;
    public static String DB_NAME = "bxg.db";
    public static final String U_USERINFO = "userinfo";
    public static final String U_VIDEO_PLAY_LIST= "videoplaylist2";
    public SQLiteHeloer(@Nullable Context context) {

        super(context, DB_NAME, null,DB_VERSION);
    }



    @Override
    public void onCreate(SQLiteDatabase db) {

        String sql1 = "CREATE TABLE IF NOT EXISTS "+U_USERINFO+"("
                +"_id integer primary key autoincrement,"
                +"userName varchar,"
                +"nickName varchar,"
                +"sex varchar,"
                +"signature varchar"
                +")";
        db.execSQL(sql1);
        String sql2 = "CREATE TABLE IF NOT EXISTS "+U_VIDEO_PLAY_LIST + "( "+"_id INTEGER PRIMARY KEY AUTOINCREMENT, "
                +"userName VARCHAR, "
                +"chapterId INT, "
                +"videoId INT, "
                +"videoPath VARCHAR, "
                +"title VARCHAR, "
                +"secondTitle VARCHAR"
                +")";
        db.execSQL(sql2);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "+ U_USERINFO);
        db.execSQL("DROP TABLE IF EXISTS "+ U_VIDEO_PLAY_LIST);
        onCreate(db);
    }
    }

